package com.hades.xq.seckill.service;

import com.hades.xq.seckill.base.CommonReturnType;
import com.hades.xq.seckill.dao.dto.TbSeckill;
import com.hades.xq.seckill.exceptions.RepeatKillException;
import com.hades.xq.seckill.exceptions.SeckillClosedException;
import com.hades.xq.seckill.exceptions.SeckillException;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface SeckillService {

    /**
     * 秒杀活动开始，输出秒杀接口地址，否则输出秒杀系间和系统时间
     *
     * @param seckillId
     */
    CommonReturnType exportSeckillUrl(Long seckillId) throws RepeatKillException;

    /**
     * 执行秒杀操作
     *
     * @param seckillId
     * @param userPhone
     * @param md5
     */
    CommonReturnType executeSeckill(Long seckillId, Long userPhone, String md5) throws SeckillException, SeckillClosedException, RepeatKillException;

    /**
     * 减库存
     *
     * @param seckillId
     * @param killTime
     * @return
     */
    int reduceNumber(@Param("seckillId") Long seckillId, @Param("killTime") Date killTime);

    /**
     * 根据ID查询秒杀商品
     *
     * @param seckillId
     * @return
     */
    TbSeckill quaryById(Long seckillId);

    /**
     * 根据偏移量查询秒杀商品列表
     *
     * @param offet
     * @param limit
     * @return
     */
    List<TbSeckill> quaryAll(int offet, int limit);
}
